package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BatteryRealTimeStatus;
import com.ruoyi.system.service.IBatteryRealTimeStatusService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 电池实时状态Controller
 * 
 * @author ruoyi
 * @date 2023-11-14
 */
@RestController
@RequestMapping("/system/status")
public class BatteryRealTimeStatusController extends BaseController
{
    @Autowired
    private IBatteryRealTimeStatusService batteryRealTimeStatusService;

    /**
     * 查询电池实时状态列表
     */
    @PreAuthorize("@ss.hasPermi('system:status:list')")
    @GetMapping("/list")
    public TableDataInfo list(BatteryRealTimeStatus batteryRealTimeStatus)
    {
        startPage();
        List<BatteryRealTimeStatus> list = batteryRealTimeStatusService.selectBatteryRealTimeStatusList(batteryRealTimeStatus);
        return getDataTable(list);
    }

    /**
     * 导出电池实时状态列表
     */
    @PreAuthorize("@ss.hasPermi('system:status:export')")
    @Log(title = "电池实时状态", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BatteryRealTimeStatus batteryRealTimeStatus)
    {
        List<BatteryRealTimeStatus> list = batteryRealTimeStatusService.selectBatteryRealTimeStatusList(batteryRealTimeStatus);
        ExcelUtil<BatteryRealTimeStatus> util = new ExcelUtil<BatteryRealTimeStatus>(BatteryRealTimeStatus.class);
        util.exportExcel(response, list, "电池实时状态数据");
    }

    /**
     * 获取电池实时状态详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:status:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(batteryRealTimeStatusService.selectBatteryRealTimeStatusById(id));
    }

    /**
     * 新增电池实时状态
     */
    @PreAuthorize("@ss.hasPermi('system:status:add')")
    @Log(title = "电池实时状态", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BatteryRealTimeStatus batteryRealTimeStatus)
    {
        return toAjax(batteryRealTimeStatusService.insertBatteryRealTimeStatus(batteryRealTimeStatus));
    }

    /**
     * 修改电池实时状态
     */
    @PreAuthorize("@ss.hasPermi('system:status:edit')")
    @Log(title = "电池实时状态", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BatteryRealTimeStatus batteryRealTimeStatus)
    {
        return toAjax(batteryRealTimeStatusService.updateBatteryRealTimeStatus(batteryRealTimeStatus));
    }

    /**
     * 删除电池实时状态
     */
    @PreAuthorize("@ss.hasPermi('system:status:remove')")
    @Log(title = "电池实时状态", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(batteryRealTimeStatusService.deleteBatteryRealTimeStatusByIds(ids));
    }
}
